package com.dc.controller;

import com.dc.annotation.Log;
import com.dc.annotation.UnCheckToken;
import com.dc.common.ResponseResultVO;
import com.dc.entity.InspectionWorkOrderRelation;
import com.dc.entity.ro.InspectionWorkOrderRO;
import com.dc.entity.vo.InspectionVO;
import com.dc.entity.vo.RoutePositionVO;
import com.dc.service.InspectionWorkOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@Api(tags = "巡检管理")
@RestController
@RequestMapping("/inspectionWorkOrder")
public class InspectionWorkOrderController {

    @Resource
    private InspectionWorkOrderService inspectionWorkOrderService;


    @Log(title = "巡检管理", businessDesc = "巡检上报")
    @ApiOperation(value = "巡检上报", notes = "巡检上报")
    @PostMapping("/insertInspectionWorkOrder")
    public ResponseResultVO insertInspectionWorkOrder(@RequestBody InspectionWorkOrderRO ro) {
        return inspectionWorkOrderService.newInsertInspectionWorkOrder(ro);
    }


    @Log(title = "巡检管理", businessDesc = "修改")
    @ApiOperation(value = "修改", notes = "修改")
    @PostMapping("/updateInspectionWorkOrder")
    public ResponseResultVO updateInspectionWorkOrder(@RequestBody InspectionWorkOrderRO ro) {
        return inspectionWorkOrderService.updateInspectionWorkOrder(ro);
    }


    @Log(title = "巡检管理", businessDesc = "删除")
    @ApiOperation(value = "删除", notes = "删除")
    @GetMapping("/deleteInspectionWorkOrder")
    public ResponseResultVO deleteInspectionWorkOrder(@RequestParam String id) {
        return inspectionWorkOrderService.deleteInspectionWorkOrder(id);
    }

    @ApiOperation(value = "分页查询巡检列表", notes = "分页查询巡检列表")
    @PostMapping("/selectWorkOrderByPage")
    public ResponseResultVO<InspectionVO> selectWorkOrderByPage(@RequestBody InspectionWorkOrderRO ro) {
        return inspectionWorkOrderService.selectWorkOrderByPage(ro);
    }

    @ApiOperation(value = "通过id查询巡检详情分页", notes = "通过id查询巡检详情分页")
    @PostMapping("/selectWorkOrderDetailByPage")
    public ResponseResultVO<InspectionWorkOrderRelation> selectWorkOrderDetailByPage(@RequestBody InspectionWorkOrderRO ro) {
        return inspectionWorkOrderService.selectWorkOrderDetailByPage(ro);
    }

    @ApiOperation(value = "列表导出", notes = "列表导出")
    @PostMapping("/inspectionRouteListExport")
    public void inspectionRouteListExport(HttpServletResponse response, @RequestBody InspectionWorkOrderRO ro) {
        inspectionWorkOrderService.inspectionRouteListExport(response, ro);
    }

    @ApiOperation(value = "二维码id获取路线点位区域信息", notes = "二维码id获取路线点位区域信息")
    @GetMapping("/check")
    @UnCheckToken(name = "/dc-control-base", url = "/inspectionWorkOrder/check")
    public ResponseResultVO<RoutePositionVO> qrCodeVerification(String id) {
        return inspectionWorkOrderService.qrCodeVerification(id);
    }

    @ApiOperation(value = "详情信息", notes = "详情信息")
    @GetMapping("/selectInspectionWorkOrder")
    public ResponseResultVO selectInspectionWorkOrder(@RequestParam String id) {
        return inspectionWorkOrderService.selectInspectionWorkOrder(id);
    }

}
